
#include <QCoreApplication>

#include "appSettings.h"

//-----------------------------------------------------------------
ApplicationSettings::ApplicationSettings() {
}

//-----------------------------------------------------------------
ApplicationSettings::~ApplicationSettings() {
}

//-----------------------------------------------------------------
void ApplicationSettings::setRegGroupCompany(QString name) {
    REG_GROUP_COMPANY = name;
}

//-----------------------------------------------------------------
void ApplicationSettings::setRegGroupApplication(QString name) {
    REG_GROUP_APPLICATION = name;
}

//-----------------------------------------------------------------
void ApplicationSettings::setRegGroupProperties(QString regGroupCompany,
                                                QString regGroupApplication) {
    REG_GROUP_COMPANY     = regGroupCompany;
    REG_GROUP_APPLICATION = regGroupApplication;

    appSettings = new QSettings(REG_GROUP_COMPANY, REG_GROUP_APPLICATION);
}

//-----------------------------------------------------------------
QString ApplicationSettings::getSettingProperty(const QString &group,
                                                const QString &setting_property) {
    QString tmp(group);
    tmp += "/";
    tmp += setting_property;
    return tmp;
}

//-----------------------------------------------------------------
void ApplicationSettings::setSettingProperty(const QString &group,
                                             const QString &property,
                                             QVariant val) {
    appSettings->beginGroup(group);
    appSettings->setValue(property, val);
    appSettings->endGroup();
}

//-----------------------------------------------------------------
bool ApplicationSettings::getBoolProperty(const QString &group,
                                          const QString &property) {
    QString tmp = getSettingProperty(group, property);
    return appSettings->value(tmp).toBool();
}
//-----------------------------------------------------------------

